AC_INIT(LibBancoMY, 1.0.1, alcione.sombra@gmail.com, libbancomy, http://www.alcionesytes.net)
AC_PREREQ([2.50])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([1.11 gnu -Wall])
AM_INIT_AUTOMAKE([dist-lzma])
AC_CONFIG_MACRO_DIR([m4])
m4_pushdef([AC_INCLUDES_DEFAULT], [$1])
AC_COPYRIGHT([Alcione Ferreira])
AC_REVISION([$Revision: 1.0.1 $])

AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
#LT_INIT([disable-static])
AC_LANG([C++])

######################################################################
# DOXYGEN SUPPORT
######################################################################

DX_HTML_FEATURE(ON)
DX_CHM_FEATURE(OFF)
DX_CHI_FEATURE(OFF)
DX_MAN_FEATURE(OFF)
DX_RTF_FEATURE(OFF)
DX_XML_FEATURE(OFF)
DX_PDF_FEATURE(ON)
DX_PS_FEATURE(ON)

DX_INIT_DOXYGEN([$PACKAGE_NAME],[doxygen.cfg],[doc])

######################################################################

AM_PROG_LIBTOOL
AC_LIBTOOL_WIN32_DLL
AC_CHECK_TOOL(AR, ar, ar)
AC_PREFIX_DEFAULT([/usr])
#WITH_MYSQL
AC_CHECK_PROGS([MY_CONFIG], [mysql_config])
if test x"$MY_CONFIG" = x; then
	AC_MSG_ERROR([$PACKAGE requires mysql_config])
fi
AC_SUBST([MY_LIBS],[`$MY_CONFIG --libs`])
AC_SUBST([MY_CFLAGS],[`$MY_CONFIG --cflags`])
AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool)
AC_CHECK_TOOL(DLLWRAP, dllwrap, dllwrap)
AC_CHECK_TOOL(WINDRES, windres, windres)
LIBBANCOMY_DLL_IMPORT=
case "$PORTNAME" in
win32 )
  if test X"$enable_shared" = Xyes; then
    AC_TRY_LINK_FUNC([libbancomy_is_dll],
    					[LIBBANCOMY_DLL_IMPORT=-DLIBBANCOMY_DLL_IMPORT])
    CFLAGS="$CFLAGS -I$(prefix)/include "
    CXXFLAGS="$CXXFLAGS -I$(prefix)/include "

    LDFLAGS="$LDFLAGS -L$(prefix)/bin -L$(prefix)/lib -lws2_32 -lz "
    
  fi
  ;;
esac
AC_SUBST([LIBBANCOMY_DLL_IMPORT])
AC_SUBST([BANCOMY_DLL_FLAGS])
AC_SUBST([AM_CXXFLAGS])
#PKG_CHECK_MODULES([EX], [libex-1.0 >= 1.0])

AC_HEADER_STDC
AC_CHECK_HEADERS([iostream string fstream vector])
AC_CHECK_HEADERS([ctime cstdio cstdlib ctype.h ltdl.h dlfcn.h])
AC_SEARCH_LIBS([lt_dlopen], [ltdl])
AC_SEARCH_LIBS([dlopen], [dl])

AC_SUBST([LIBBANCOMY_SO_VERSION], [1:0:1])
AC_SUBST([LIBBANCOMY_API_VERSION], [1.0])

AC_CONFIG_FILES([Makefile src/Makefile libbancomy-${LIBBANCOMY_API_VERSION}.pc:libbancomy.pc.in])

AC_OUTPUT
